using System;
using System.Collections.Generic;
using Common;
namespace DRE {
	public class Inventory:IRegisterManager<Inventory.Section> {
		public Inventory(){
			Register(new Section("Normal"));
			Register(new Section("Key"));
			Register(new Section("Weapon"));
			Register(new Section("Armor"));
		}
		public struct Position {
			public Position(string section, int slot) {
				Section = section;
				Slot = slot;
			}

			/// <summary>
			/// Section of the target item slot is in.
			/// </summary>
			public string Section { get; set; }

			/// <summary>
			/// Target item slot.
			/// </summary>
			public int Slot { get; set; }
		}
		public class Section:IRegisterable{
			public Section(string id){
				Id=id;
			}
			public string Id{get;}
			List<string> items=new List<string>();
			// TODO: Implement IList
		}

		Dictionary<string,Section> sections=new Dictionary<string, Section>();
		public void Register(Section section) {
			if (IsExists(section.Id)) {
				throw new ArgumentException("An inventory section with the same ID: " + section.Id + " is already registered!");
			}
			sections.Add(section.Id, section);
		}
		public bool IsExists(string id)=>sections.ContainsKey(id);
		public Section Get(string id)=>IsExists(id)?sections[id]:null;
		public void Remove(string id)=>sections.Remove(id);
		public void Clear()=>sections.Clear();
		public Section this[string id]=>Get(id);
	}
}
